home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Controller / MCComponent ƒ / HideMenuBar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-14  |  2.5 KB  |  114 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        HideMenuBar.c
  3.  
  4.     Contains:    code snippet for hiding menu bar.
  5.  
  6.     Written by:    John Wang
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <1>        03/14/94    JW        Re-Created for Universal Headers.
  13.  
  14.     To Do:
  15.  
  16. */
  17.  
  18. #ifdef THINK_C
  19. #define        applec
  20. #endif
  21.  
  22. #include    <Memory.h>
  23. #include    <QuickDraw.h>
  24. #include    <LowMem.h>
  25.  
  26. #include    "HideMenuBar.h"
  27.  
  28. typedef struct    {                        
  29.     short                oldMBarHeight;
  30.     RgnHandle            theBarRgn;
  31. } MenuBarGlobals;
  32.  
  33. /* ------------------------------------------------------------------------- */
  34.  
  35. /*
  36.     Description:    Call this routine to hide menu bar.
  37.  
  38.     Format Params:    
  39.         Name            Usage    Description/Assumptions
  40.         ----            ----    -----------------------
  41.         return            R        Returns a handle that must be passed back to RestoreMenuBar().
  42.                 
  43.     Usage: P=Parameter,R=ReturnValue,E=External,G=FileGlobal,L=Local,I=Input,O=Output
  44.     
  45.     Error Handling:    Return nil if failed.
  46.  
  47.     Special Notes:    xxx put other comments here xxx
  48.  
  49. */
  50.  
  51. Handle HideMenuBar()
  52. {
  53.     Rect                mBarRect;
  54.     RgnHandle            mBarRgn;
  55.     MenuBarGlobals        **myHandle;
  56.     Rect                myDeviceRect, myMainDeviceRect;
  57.     
  58.     myHandle = (MenuBarGlobals **) NewHandleClear(sizeof(MenuBarGlobals));
  59.     if ( myHandle == nil )
  60.         goto bail;
  61.         
  62.     myMainDeviceRect = (**GetMainDevice()).gdRect;
  63.     
  64.     (**myHandle).oldMBarHeight = GetMBarHeight();
  65.     LMSetMBarHeight(0);
  66.     SetRect(&mBarRect, myMainDeviceRect.left, myMainDeviceRect.top,
  67.             myMainDeviceRect.right, myMainDeviceRect.top + (**myHandle).oldMBarHeight);
  68.     mBarRgn = NewRgn();
  69.     RectRgn(mBarRgn, &mBarRect);
  70.     UnionRgn(LMGetGrayRgn(), mBarRgn, LMGetGrayRgn());
  71.     (**myHandle).theBarRgn = mBarRgn;
  72.     
  73. bail:
  74.     return( (Handle) myHandle );
  75. }
  76.  
  77. /* ------------------------------------------------------------------------- */
  78.  
  79. /*
  80.     Description:    Call this routine to restore menu bar.
  81.  
  82.     Format Params:    
  83.         Name            Usage    Description/Assumptions
  84.         ----            ----    -----------------------
  85.         theHandle        PI        Contains info to restore menu bar.
  86.                 
  87.     Usage: P=Parameter,R=ReturnValue,E=External,G=FileGlobal,L=Local,I=Input,O=Output
  88.     
  89.     Error Handling:    If passed nil handle, then just quit.
  90.  
  91.     Special Notes:    xxx put other comments here xxx
  92.  
  93. */
  94.  
  95. void RestoreMenuBar(Handle theHandle)
  96. {
  97.     RgnHandle            mBarRgn;
  98.     MenuBarGlobals        **myHandle;
  99.     
  100.     if (theHandle == nil)
  101.         goto bail;
  102.     myHandle = (MenuBarGlobals **) theHandle;
  103.         
  104.     //    Restore menu bar.
  105.     LMSetMBarHeight((**myHandle).oldMBarHeight);
  106.     mBarRgn = (**myHandle).theBarRgn;
  107.     DiffRgn(LMGetGrayRgn(), mBarRgn, LMGetGrayRgn());
  108.     DisposeRgn(mBarRgn);
  109.     DrawMenuBar();
  110.     
  111. bail:
  112.     if (theHandle != nil)
  113.         DisposHandle(theHandle);
  114. }